<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="活动时间" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <!-- <j-input placeholder v-model="queryParam.eventTime"></j-input> -->
              <j-date placeholder="请选择活动时间" v-model="queryParam.eventTime" :trigger-change="true" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="活动类型" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <j-input placeholder v-model="queryParam.eventType"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 21px">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>


    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('社团活动管理')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete" />删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down" />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
        :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap" @change="handleTableChange">
        
        
        <template slot="piclot" slot-scope="text, record">
            <viewer>
              <img  :src="record.posters" width="200" height="140" />
            </viewer>
        </template>
        
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">下载</a-button>
        </template>

        <span slot="action" slot-scope="text, record">
<!--            <a-switch :default-checked="false" @change='onChange($event,record)' v-if="record.audit== 3" />
            <a-switch :default-checked="true" @change='onChange($event,record)' v-if="record.audit== 2" />
            <a-switch :default-checked="false" @change='onChange($event,record)' v-if="record.audit== 1" />
          <a-divider type="vertical" /> -->
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="getClubEventInfo(record.id)">详情</a>
              </a-menu-item>
              <a-menu-item v-if="record.delFlag == '1'">
                <a-popconfirm title="确定删除吗?" @confirm="() => batchDels(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
              
              <a-menu-item v-if="record.delFlag == '2'">
                <a-popconfirm title="确定恢复吗?" @confirm="() => batchDels(record.id)">
                  <a>恢复</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>

    <club-event-management-modal ref="modalForm" @ok="modalFormOk"></club-event-management-modal>

    <!-- ///////////  用户详情对话框 开始 -->
    <a-modal v-model="visible" title="Basic Modal" @ok="handleOk">
      <p>活动名称: &nbsp;{{clubEventInfo.eventName}}</p>
      <p>活动海报: &nbsp; <viewer><img :src="this.clubEventInfo.posters" width="100%" height="100%  "/></viewer> </p>
      <p>举办方: &nbsp; {{clubEventInfo.clubName}}</p>
      <p>所属学校: &nbsp; {{clubEventInfo.schoolName}}</p>
      <p>活动类型: &nbsp; {{clubEventInfo.eventTypeName}} </p>
      <p>活动性质: &nbsp; {{clubEventInfo.eventNatureName}} </p>
      <p>活动说明: &nbsp; {{clubEventInfo.explanation}} </p>
      <p>活动时间: &nbsp; {{clubEventInfo.eventTime}} </p>
      <p>活动地址: &nbsp; {{clubEventInfo.address}} </p>
      <p>活动纪实: &nbsp; {{clubEventInfo.address}} </p>
      <p>评论数量: &nbsp; {{clubEventInfo.commentNum}} </p>
      <p>点赞数量: &nbsp; {{clubEventInfo.likes}} </p>
      <p>报名人数: &nbsp; {{clubEventInfo.enlistsNum}} </p>
      <p v-if="clubEventInfo.enrollStatus == '1'">状态: &nbsp; 未开始 </p>
      <p v-else-if="clubEventInfo.enrollStatus == '2'">状态: &nbsp; 已开始 </p>
      <p v-else-if="clubEventInfo.enrollStatus == '3'">状态: &nbsp; 已结束 </p>
<!-- 活动报名状态,1:未开始,2:已开始,3:已结束 -->

      <!-- <p v-if="this.userInfo.myJoinClub != null">加入社团: &nbsp; <br/>
        <col v-for="club in myJoinClub">
          头像:{{club.avatar}} <br />
          名称:{{club.name}} <br />
          所属学校:{{club.schoolName}} <br />
        </col>
      </p> -->
    </a-modal>
    <!-- 用户详情对话框 结束 -->
  </a-card>


</template>

<script>
  import '@/assets/less/TableExpand.less'
  import {
    mixinDevice
  } from '@/utils/mixin'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import {
    putAction,
    postAction
  } from '@/api/manage'
  import ClubEventManagementModal from './modules/ClubEventManagementModal'
  import JInput from '@comp/jeecg/JInput'
  import JDate from '@/components/jeecg/JDate'

  export default {
    name: 'ClubEventManagementList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      ClubEventManagementModal,
      JInput,
      JDate
    },
    data() {
      return {
        visible: false,
        clubEventInfo: {},
        outerVisible: false,
        innerVisible: false,
        description: '社团活动管理管理页面',
        // 表头
        columns: [{
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '活动名称',
            align: 'center',
            dataIndex: 'eventName'
          },
          {
            title: '活动类型',
            align: 'center',
            dataIndex: 'eventTypeName'
          },
          {
            title: '活动时间',
            align: 'center',
            dataIndex: 'eventTime',
            customRender: function(text) {
              return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
            }
          },
          {
            title: '活动性质',
            align: 'center',
            dataIndex: 'eventNatureName'
          },
          {
            title: '举办方',
            align: 'center',
            dataIndex: 'clubName'
          },
          {
            title: '活动说明',
            align: 'center',
            dataIndex: 'explanation'
          },
          {
            title: '海报',
            align: 'center',
            dataIndex: 'posters',
            scopedSlots: { customRender: 'piclot' }
            
          },
          {
            title: '审核',
            align: 'center',
            dataIndex: 'audit_dictText'
          },
          // {
          //   title:'活动地址',
          //   align:"center",
          //   dataIndex: 'address'
          // },
          // {
          //   title:'活动纪实',
          //   align:"center",
          //   dataIndex: 'activityDocumentary'
          // },
          // {
          //   title:'社团ID',
          //   align:"center",
          //   dataIndex: 'clubId'
          // },
          // {
          //   title:'点赞数',
          //   align:"center",
          //   dataIndex: 'likes'
          // },
          // {
          //   title:'评论数',
          //   align:"center",
          //   dataIndex: 'commentNum'
          // },
          // {
          //   title: '删除',
          //   align: 'center',
          //   dataIndex: 'delFlag_dictText'
          // },
          // {
          //   title:'学校ID',
          //   align:"center",
          //   dataIndex: 'schoolId'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],
        url: {
          list: '/clubEventManagement/clubEventManagement/list',
          delete: '/clubEventManagement/clubEventManagement/delete',
          deleteBatch: '/clubEventManagement/clubEventManagement/deleteBatch',
          exportXlsUrl: '/clubEventManagement/clubEventManagement/exportXls',
          importExcelUrl: 'clubEventManagement/clubEventManagement/importExcel'
        },
        dictOptions: {}
      }
    },
    created() {},
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      batchDels(id) {
        this.axios.get('/clubEventManagement/clubEventManagement/deleteById',{params:{id:id}}).then((res) => {
          this.loadData();
        })
        },
      // audit(id) {
      //   getAction("/clubEventManagement/clubEventManagement/activityReview",{id}).then(res => {
      //     if (res.success) {
      //       let arr = res.result
      //       this.nameList_jiaohsi = arr
      //       this.loadData()
      //       this.onClearSelected()
      //     } else {
      //       this.$message.warning(res.message)
      //     }
      //   })
      // },
      initDictConfig() {},
      getClubEventInfo(id) { //获取 社团活动详情
        this.axios.get("/clubEventManagement/clubEventManagement/getClubEventInfo", {
          params: {
            id: id
          }
        }).then((res) => {
          this.clubEventInfo = res.result;
          this.visible = true;
        })
      },
      handleOk(e) {
        console.log(e);
        this.visible = false;
      },
      onChange(event,record){
         if(event){
           //审核通过
           record.audit = '2';
         }else{
           record.audit = '3';
         }
         this.axios.post("/clubEventManagement/clubEventManagement/activityReview", record).then((res) => {
           this.loadData();
         })
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
